package im.composer.io;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;

public class MyFiles {

	public static final boolean supportsRandomAccess(Path path){
		if(path==null){
			return false;
		}
		if(path.toUri().getScheme().equalsIgnoreCase("file")){
			return true;
		}
		try {
			Map<String,Object> map = Files.readAttributes(path, "zdl:random_access");
			if(map==null){
				return false;
			}
			return Boolean.parseBoolean(String.valueOf(map.get("zdl:random_access")));
		} catch (IOException e) {
			return false;
		}
	}
	
}
